package standard.util;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;

/**
 * Create by Lingo
 */

public enum MysqlTypeEnum {
    DECIMAL("DECIMAL", 3,"DECIMAL"),
    DECIMAL_UNSIGNED("DECIMAL UNSIGNED", 3,"DECIMAL"),
    TINYINT("TINYINT", -6,"TINYINT"),
    TINYINT_UNSIGNED("TINYINT UNSIGNED", -6,"TINYINT"),
    BOOLEAN("BOOLEAN", 16,"BOOLEAN"),
    SMALLINT("SMALLINT", 5,"SMALLINT"),
    SMALLINT_UNSIGNED("SMALLINT UNSIGNED", 5,"SMALLINT"),
    INT("INT", 4,"INTEGER"),
    INT_UNSIGNED("INT UNSIGNED", 4,"INTEGER"),
    FLOAT("FLOAT", 7,"FLOAT"),
    FLOAT_UNSIGNED("FLOAT UNSIGNED", 7,"FLOAT"),
    DOUBLE("DOUBLE", 8,"DOUBLE"),
    DOUBLE_UNSIGNED("DOUBLE UNSIGNED", 8,"DOUBLE"),
    NULL("NULL", 0,"NULL"),
    TIMESTAMP("TIMESTAMP", 93,"TIMESTAMP"),
    BIGINT("BIGINT", -5,"BIGINT"),
    BIGINT_UNSIGNED("BIGINT UNSIGNED", -5,"BIGINT"),
    MEDIUMINT("MEDIUMINT", 4,"MEDIUMINT"),
    MEDIUMINT_UNSIGNED("MEDIUMINT UNSIGNED", 4,"MEDIUMINT"),
    DATE("DATE", 91,"DATE"),
    TIME("TIME", 92,"TIME"),
    DATETIME("DATETIME", 93,"DATETIME"),
    YEAR("YEAR", 91,"YEAR"),
    VARCHAR("VARCHAR", 12,"VARCHAR"),
    VARBINARY("VARBINARY", -3,"VARBINARY"),
    BIT("BIT", -7,"BIT"),
    JSON("JSON", -1,"JSON"),
    ENUM("ENUM", 1,"ENUM"),
    SET("SET", 1,"SET"),
    TINYBLOB("TINYBLOB", -3,"TINYBLOB"),
    TINYTEXT("TINYTEXT", 12,"TINYTEXT"),
    MEDIUMBLOB("MEDIUMBLOB", -4,"MEDIUMBLOB"),
    MEDIUMTEXT("MEDIUMTEXT", -1,"MEDIUMTEXT"),
    LONGBLOB("LONGBLOB", -4,"LONGBLOB"),
    LONGTEXT("LONGTEXT", -1,"LONGTEXT"),
    BLOB("BLOB", -4,"BLOB"),
    TEXT("TEXT", -1,"TEXT"),
    CHAR("CHAR", 1,"CHAR"),
    BINARY("BINARY", -2,"BINARY"),
    GEOMETRY("GEOMETRY", -2,"GEOMETRY"),
    UNKNOWN("UNKNOWN", 1111,"UNKNOWN"),
    ;

    private final int typeInt;
    private final String jdbcName;
    private final String mybatisName;

    MysqlTypeEnum(String jdbcName,int typeInt,  String mybatisName) {
        this.typeInt = typeInt;
        this.jdbcName = jdbcName;
        this.mybatisName = mybatisName;
    }

    public static String getMybatisName(int typeInt) {
        for (MysqlTypeEnum value : MysqlTypeEnum.values()) {
            if (value.typeInt == typeInt) {
                return value.mybatisName;
            }
        }
        return "NOT FOUND";
    }

    public static String getJdbcName(int typeInt) {
        for (MysqlTypeEnum value : MysqlTypeEnum.values()) {
            if (value.typeInt == typeInt) {
                return value.jdbcName;
            }
        }
        return "NOT FOUND";
    }

}
